local zhuilie = fk.CreateSkill {

  name = "joy__zhuilie",

  tags = { Skill.Compulsory, },

}



zhuilie:addEffect(fk.TargetSpecified, {
  name = "joy__zhuilie",
  anim_type = "offensive",
  frequency = Skill.Compulsory,
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhuilie.name) and data.card.trueName == "slash" and
      not player:inMyAttackRange(player.room:getPlayerById(data.to))
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:addCardUseHistory(data.card.trueName, -1)
    local judge = {
      who = player,
      reason = zhuilie.name,
      pattern = ".",
    }
    room:judge(judge)
    if judge.card.sub_type and (judge.card.sub_type == Card.SubtypeWeapon or
      judge.card.sub_type == Card.SubtypeOffensiveRide or judge.card.sub_type == Card.SubtypeDefensiveRide) then
      data.additionalDamage = (data.additionalDamage or 0) + room:getPlayerById(data.to).hp - 1
    elseif judge.card.type == Card.TypeTrick and room:getCardArea(judge.card.id) == Card.Processing then
      room:obtainCard(player,judge.card,true,fk.ReasonPrey,player.id,zhuilie.name)
    elseif judge.card.type == Card.TypeBasic then
      room:loseHp(player, 1, zhuilie.name)
    end
  end,
})

zhuilie:addEffect("targetmod", {
  name = "#joy__zhuilie_targetmod",
  bypass_distances =  function(self, player, skill)
    return player:hasSkill(zhuilie.name) and skill.trueName == "slash_skill"
  end,
})

return zhuilie